home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / gs3.53 / gs_statd.ps < prev    next >
Text File  |  1996-01-10  |  10KB  |  258 lines

  1. %    Copyright (C) 1989, 1995 Aladdin Enterprises.  All rights reserved.
  2. % This file is part of Aladdin Ghostscript.
  3. % Aladdin Ghostscript is distributed with NO WARRANTY OF ANY KIND.  No author
  4. % or distributor accepts any responsibility for the consequences of using it,
  5. % or for whether it serves any particular purpose or works at all, unless he
  6. % or she says so in writing.  Refer to the Aladdin Ghostscript Free Public
  7. % License (the "License") for full details.
  8. % Every copy of Aladdin Ghostscript must include a copy of the License,
  9. % normally in a plain ASCII text file named PUBLIC.  The License grants you
  10. % the right to copy, modify and redistribute Aladdin Ghostscript, but only
  11. % under certain conditions described in the License.  Among other things, the
  12. % License requires that the copyright notice and this notice be preserved on
  13. % all copies.
  14.  
  15. % This file provides statusdict, serverdict, and assorted LaserWriter
  16. % operators, mostly for the benefit of poorly designed PostScript programs
  17. % that 'know' they are running on a LaserWriter.
  18.  
  19. systemdict begin
  20.     % We make statusdict a little larger for Level 2 stuff.
  21.     % Note that it must be allocated in local VM.
  22.  .currentglobal false .setglobal
  23.  /statusdict 89 dict def
  24.     % To support the Level 2 job control features,
  25.     % serverdict must also be in local VM.
  26.  /serverdict 10 dict def        % ditto
  27.  .setglobal
  28. end
  29.  
  30. % Define various paper formats.  The Adobe documentation defines only these:
  31. % 11x17, a3, a4, a4small, b5, ledger, legal, letter, lettersmall, note.
  32. % These procedures are also accessed as data structures during initialization,
  33. % so the page dimensions must be the first two elements of the procedure.
  34.  
  35. /.setpagesize { //systemdict /statusdict get begin .setpagesize end } bind def
  36. userdict begin
  37.  /letter {612 792 //.setpagesize exec} bind def
  38. % 'note' is an anomaly.  It is apparently supposed to use a 540x720 region
  39. % centered on a 612x792 page, with (0,0) at the lower left corner of the
  40. % 612x792 page, but we have no way to represent this.  In order to avoid
  41. % clipping the image, we define note as equivalent to letter.
  42. %/note {540 720 //.setpagesize exec} bind def
  43.  /note /letter load def
  44.  /legal {612 1008 //.setpagesize exec} bind def
  45.  /a0 {2380 3368 //.setpagesize exec} bind def  % ISO standard
  46.  /a1 {1684 2380 //.setpagesize exec} bind def  % ISO standard
  47.  /a2 {1190 1684 //.setpagesize exec} bind def  % ISO standard
  48.  /a3 {842 1190 //.setpagesize exec} bind def  % ISO standard
  49.  /a4 {595 842 //.setpagesize exec} bind def  % ISO standard
  50.  /a5 {421 595 //.setpagesize exec} bind def  % ISO standard
  51.  /a6 {297 421 //.setpagesize exec} bind def  % ISO standard
  52.  /a7 {210 297 //.setpagesize exec} bind def  % ISO standard
  53.  /a8 {148 210 //.setpagesize exec} bind def  % ISO standard
  54.  /a9 {105 148 //.setpagesize exec} bind def  % ISO standard
  55.  /a10 {74 105 //.setpagesize exec} bind def  % ISO standard
  56.  /b0 {2836 4008 //.setpagesize exec} bind def  % ISO standard
  57.  /b1 {2004 2836 //.setpagesize exec} bind def  % ISO standard
  58.  /b2 {1418 2004 //.setpagesize exec} bind def  % ISO standard
  59.  /b3 {1002 1418 //.setpagesize exec} bind def  % ISO standard
  60.  /b4 {709 1002 //.setpagesize exec} bind def  % ISO standard
  61.  /b5 {501 709 //.setpagesize exec} bind def  % ISO standard
  62.  /archE {2592 3456 //.setpagesize exec} bind def % U.S. CAD std
  63.  /archD {1728 2592 //.setpagesize exec} bind def % U.S. CAD std
  64.  /archC {1296 1728 //.setpagesize exec} bind def % U.S. CAD std
  65.  /archB {864 1296 //.setpagesize exec} bind def  % U.S. CAD std
  66.  /archA {648 864 //.setpagesize exec} bind def  % U.S. CAD std
  67.  /flsa {612 936 //.setpagesize exec} bind def  % U.S. foolscap
  68.  /flse {612 936 //.setpagesize exec} bind def  % European foolscap
  69.  /halfletter {396 612 //.setpagesize exec} bind def
  70.  /11x17 {792 1224 //.setpagesize exec} bind def  % 11x17 portrait
  71.  /ledger {1224 792 //.setpagesize exec} bind def  % 11x17 landscape
  72. end
  73. currentdict /.setpagesize undef
  74.  
  75. statusdict begin
  76.  
  77. % Define the pagetype values for the known page formats.
  78. % The values for all but letter and note are arbitrary.
  79. /.pagetypenames
  80.  { /letter /note /legal 
  81.    /a0 /a1 /a2 /a3 /a4 /a5 /a6 /a7 /a8 /a9 /a10
  82.    /b0 /b1 /b2 /b3 /b4 /b5 /archE /archD /archC /archB /archA
  83.    /flsa /flse /halfletter /11x17 /ledger
  84.  } cvlit readonly def
  85.  
  86. %%%%%% The following items were suggested by a user as useful.
  87.  
  88. % Permanent definitions
  89.  
  90. /ramsize         4194304 def
  91. /hardwareiomode        0 def
  92.     /sethardwareiomode     {pop} bind def
  93. /softwareiomode        0 def
  94.     /setsoftwareiomode     {pop} bind def
  95. /dosysstart        false def
  96.     /setdosysstart         {pop} bind def
  97. /allowjobreset      true def
  98.     /setallowjobreset      {pop} bind def
  99. /defaultpaperfamily    0 def
  100.     /setdefaultpaperfamily {pop} bind def
  101. /defaultpapertray      0 def
  102.     /setdefaultpapertray   {pop} bind def
  103. /defaulttrayswitch false def
  104.     /setdefaulttrayswitch  {pop} bind def
  105.  
  106. % Tray and format selection
  107.  
  108.  /11x17tray userdict /11x17 get def
  109.  /a3tray userdict /a3 get def
  110.  /a4tray userdict /a4 get def
  111.  /a5tray userdict /a5 get def
  112.  /a6tray userdict /a6 get def
  113.  /b4tray userdict /b4 get def
  114.  /flsatray userdict /flsa get def
  115.  /flsetray userdict /flse get def
  116.  /halflettertray userdict /halfletter get def
  117.  /ledgertray userdict /ledger get def
  118.  /legaltray userdict /legal get def
  119.  /lettertray userdict /letter get def
  120.  
  121. % Per-job parameters
  122.  
  123. /paperfamily 0 def    % 0 is US, 1 is European
  124. /papertray 1 def
  125.     /setpapertray {statusdict exch /papertray exch put} bind def 
  126. /trayswitch false def    % paperout feeds from another tray
  127. /papersize {/letter true} bind def    % <name of paper size>, <short-edge-first-p>
  128. /appletalktype (LaserWriter) def
  129.  
  130. %%%%%% The following items are defined in the PostScript Language
  131. %%%%%% Reference Manual, First Edition, and subsequent 'compatibility'
  132. %%%%%% documentation from Adobe.
  133.  
  134.  /checkpassword {statusdict begin .password eq end} bind def
  135.  /defaulttimeouts {statusdict begin .timeouts aload pop end} bind def
  136. %/dostartpage
  137.  /eescratch {pop 0} bind def
  138.  /idlefonts {statusdict begin mark .idlefonts aload pop end} bind def
  139.  /jobname () def
  140. %/jobtimeout
  141.  /manualfeed false def
  142.  /manualfeedtimeout 60 def
  143.  /margins {statusdict begin .topmargin .leftmargin end} bind def
  144.  /pagecount {4711} bind def
  145.  /pagestackorder {false} bind def
  146.  /pagetype 0 def
  147.  /prefeed false def
  148.  /printererror {pop pop} bind def
  149.  /printername {statusdict /.printername get exch copy} bind def
  150.  /processcolors /processcolors load def        % defined in systemdict
  151.  /product product def        % product is defined in systemdict
  152.  /revision revision def        % revision is defined in systemdict
  153.  /sccbatch {pop 9600 0} bind def
  154.  /sccinteractive {pop 9600 0} bind def
  155.  /setdefaulttimeouts {statusdict begin .timeouts astore pop end} bind def
  156.  /setdostartpage {statusdict exch /dostartpage exch put} bind def
  157.  /setduplexmode {mark /Duplex 3 -1 roll currentdevice putdeviceprops} bind def
  158.  /seteescratch {pop pop} bind def
  159.  /setidlefonts {] statusdict exch /.idlefonts exch put} bind def
  160.  /setjobtimeout {statusdict exch /jobtimeout exch put} bind def
  161.  /setmargins
  162.   { statusdict begin
  163.     /.leftmargin exch def /.topmargin exch def
  164.     end
  165.   } bind def
  166.  
  167. % The following compatibility operators are only documented by Adobe in a
  168. % supplement to the Red Book.
  169. %
  170. %    - pagemargin <offset>
  171. %    - pageparams <width> <height> <offset> <orientation>
  172. %    <width> <height> <orientation> setpage -
  173. %    <offset> setpagemargin -
  174. %    <width> <height> <offset> <orientation> setpageparams -
  175. %
  176. % width and height are in default units (and if orientation is odd, are
  177. % exchanged!).  offset is the x margin, also in default units.
  178. % Unfortunately, because orientation is relative to the device paper feed,
  179. % it does not have a consistent meaning in terms of image orientation.
  180. % We follow the convention that ORIENT1 determines the orientation value
  181. % that means portait: false means 0, true means 1.
  182.  
  183.  /pagemargin { 0 } bind def
  184.  /pageparams
  185.   { currentdevice 1 dict dup /.MediaSize dup put .getdeviceparams
  186.     exch pop exch pop aload pop 0 ORIENT1 { 1 } { 0 } ifelse
  187.   } bind def
  188.  /setpage {ORIENT1 { 1 } { 0 } ifelse ne {exch} if .setpagesize} bind def
  189.  /setpagemargin {pop} bind def        % can't do better without setpagedevice
  190.  /setpageparams {exch pop ORIENT1 { 1 } { 0 } ifelse ne {exch} if .setpagesize} bind def
  191.  /setpagetype
  192.   { statusdict begin
  193.       dup .pagetypenames exch get systemdict exch get exec
  194.       /pagetype exch def
  195.     end
  196.   } bind def
  197.  /setpassword
  198.   {exch checkpassword
  199.     {statusdict exch /.password exch put true}
  200.     {pop false}
  201.    ifelse} bind def
  202.  /setprintername
  203.   {dup length string copy statusdict exch /.printername exch put} bind def
  204.  
  205. % setresolution is not documented by Adobe, but some applications
  206. % use it anyway, without testing whether or not it is present.
  207. %
  208. %    <pixels_per_inch> setresolution -
  209. %
  210. % sets the resolution of the device.
  211.  
  212.  /setresolution
  213.   { mark /HWResolution [ 4 -1 roll dup ] currentdevice putdeviceprops pop
  214.     initmatrix erasepage
  215.   } bind def
  216.  /setsccbatch {pop pop pop} bind def
  217.  /setsccinteractive {pop pop pop} bind def
  218.  /settumble {pop} bind def
  219.  /waittimeout 300 def
  220.  
  221. %%%%%% End of documented items.
  222.  
  223. /.setpagesize
  224.  { mark /HWSize [
  225.      4 index 4 index matrix defaultmatrix dtransform
  226.      abs ceiling cvi exch abs ceiling cvi exch
  227.    ] currentdevice putdeviceprops pop pop pop
  228.    initmatrix initclip erasepage
  229.  } bind def
  230. /.password 0 def
  231. /.timeouts [0 60 30] def
  232. true setdostartpage
  233. mark setidlefonts
  234. 0 setjobtimeout
  235. 0 0 setmargins
  236. product setprintername
  237.  
  238. end    % statusdict
  239.  
  240. % The following contents of serverdict are a complete guess,
  241. % based on some observed LaserWriter boilerplate.
  242.  
  243. serverdict begin
  244.  
  245.  /execjob { } bind def
  246. % The Red Book implies that something like the following is
  247. % an appropriate definition of exitserver.
  248.  /exitserver { clear stop } bind def
  249. % However, this interacts badly with our standard error handler,
  250. % so we override it with the following less appropriate definition.
  251.  /exitserver { 0 ne { clear cleardictstack } if } bind def
  252.  /setrealdevice { } bind def
  253.  
  254. end    % serverdict
  255.